<?php

class IndexController extends Controller
{
    public function actionIndex()
    {		//
	FactoryService::get('review')->getAllWithRelation(array(
	    'select' => array('t.*'),
	    'from' => REVIEW_TABLE . ' as t',
	    'join' => 'INNER JOIN user ON user.id = t.user_id LEFT JOIN category ON category.id = t.category_id',
	), array('user', 'category'));	
	$this->render('index');
    }
    
    public function actionQuestions()
    {	
	$this->render('questions', array(
	    'lastComments' => ManagerFactory::manager('comment')->getLastComments(),
	    'lastQuestions' => ManagerFactory::manager('record')->getLastQuestions(),
	    'emptyQuestions' => ManagerFactory::manager('record')->getEmptyQuestions()
	));
    }
    
    public function actionReviews()
    {	
	$this->render('reviews', array(
	    'lastReviews' => ManagerFactory::manager('record')->getLastReviews(),
	    'goodReview' => ManagerFactory::manager('opinion')->getLastRecords(),
	    'badReview' => ManagerFactory::manager('opinion')->getLastRecords('bad'),
	));
    }
    
    public function actionCategories()
    {
	$this->render('categories', array(
	    'categories' => ManagerFactory::manager('category')->getAllCategories()
	));
    }
}
